home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8226 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: qualcomm.com!usenet
  2. From: nababs@qualcomm.com (Nasser Abbasi)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: I need some help using the do/while loop
  5. Date: 15 Feb 1996 21:38:27 GMT
  6. Organization: Qualcomm Inc.
  7. Message-ID: <4g094j$pih@qualcomm.com>
  8. References: <4fp3nc$bh8@ixnews7.ix.netcom.com> <4fpg9j$dsj@qualcomm.com> <DMtn4A.I7M@udcf.gla.ac.uk>
  9. NNTP-Posting-Host: nabbasi.qualcomm.com
  10. Mime-Version: 1.0
  11. X-Newsreader: WinVN 0.93.14
  12.  
  13. In article <DMtn4A.I7M@udcf.gla.ac.uk>, dpirie@aero.gla.ac.uk says...
  14.  
  15.  
  16. >
  17. >>
  18. >> IF Number_Of_Interations Greater than 0 THEN 
  19. >********************************************************************** 
  20. >>    Miles_Per_Gallon := Total_Miles_Per_Gallon / Number_Of-Iterations
  21. >**********************************************************************
  22. >>    Output "The overall average miles/gallon was " Miles_Per_Gallon
  23. >> ELSE
  24. >>    Output "No data supplied for program"
  25. >> END IF
  26. >>
  27.  
  28.  
  29. >.........
  30. >The step which I've enclosed in rows of ******** is quite wrong.
  31. >The total miles/gallon = totalMiles/totalGallons. 
  32. >                                                          = 
  33. (M1+M2+...+Mn)/(G1+G2+...+Gn)
  34. >This does NOT = (M1/G1 + M2/G2 + ... +Mn/Gn)/n, as implied in Nasser's 
  35. pseudocode above.
  36. >
  37. >David Pirie
  38. >
  39. >
  40.  
  41.  
  42. Thanks for reviewing the code. BUT, I  was following the customer
  43. requirments :) , the original poster said to find
  44.  
  45.     "The overall average miles/gallon "
  46.  
  47. I read this to mean to find the miles/gallon for each iteration, then
  48. take the average of that, (since he asked for AVERAGE, and the average
  49. of a QUANTITY is the sum of the QUANITIES divided by 
  50. Number_Of_Interations, which is what I did).
  51.  
  52. If the original post said to "The overall miles/gallon " then you are 
  53. correct offcourse but that is not what he asked for (even though that is
  54. what it looks like he wanted actually, from looking at the sample numbers
  55. in the original post).
  56.  
  57. So, I think I was following the requirments correctly, but it seems
  58. requirments are not correct.
  59.  
  60. this is a good example that one must make sure the requirments are clear
  61. and to know what the customer wants before starting to code against them
  62. :)
  63.  
  64. Nasser
  65.  
  66.